home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / printing / magicfil.2 / magicfilter-1.2.tar / magicfilter-1.2 / magicfilter.h < prev    next >
C/C++ Source or Header  |  1995-03-29  |  2KB  |  85 lines

  1. /*
  2.  *  magicfilter.h
  3.  *
  4.  *  Copyright ⌐ 1993-95 H. Peter Anvin
  5.  *
  6.  *  Header file for the magic lpr/lpd filter
  7.  */
  8.  
  9. #include "config.h"
  10. #include <stdio.h>
  11. #ifdef HAVE_PATHS_H
  12. #include <paths.h>
  13. #endif
  14. #include <string.h>
  15. #ifdef HAVE_MEMORY_H
  16. #include <memory.h>
  17. #endif
  18. #ifdef HAVE_STDLIB_H
  19. #include <stdlib.h>
  20. #endif
  21. #include <ctype.h>
  22.  
  23. /*
  24.  * These *must* be in the same order as the table in parseconfig.c!
  25.  */
  26. enum actions
  27. {
  28.   ACT_CAT,            /* Just output the file */
  29.   ACT_DROP,            /* Silently ignore the file */
  30.   ACT_REJECT,            /* Mail the user and complain */
  31.   ACT_FILTER,            /* Run through filter, then done */
  32.   ACT_PIPETHRU,            /* Pipe through command, then reprocess */
  33.   ACT_ADDCR,            /* Like ACT_CAT, but \n -> \r\n, \f -> \r\f */
  34.   ACT_PS,            /* Like ACT_ADDCR, but add PSEOJ (^D) at end */
  35.   ACT_FFILTER,            /* Like ACT_FILTER, but use a temp file */
  36.   ACT_FPIPE,            /* Like ACT_PIPETHRU, but use a temp file */
  37.   
  38.   ACT_ERR = -1
  39. };
  40.  
  41. /*
  42.  * Special magic actions
  43.  */
  44.  
  45. #define MAG_ERR       (-1)    /* Invalid line */
  46. #define MAG_COMMENT   (-2)    /* Line is blank or comment */
  47. #define MAG_DEFAULT   (-3)    /* Action is the default action */
  48. #define MAG_SET       (-4)    /* Action is a set command */
  49.  
  50. struct datatype
  51. {
  52.   struct datatype *next;    /* Linked list pointer */
  53.   int offset;            /* Where in file is ID string */
  54.   int length;            /* Length of ID string */
  55.   char *magic;            /* Expected ID string */
  56.   char *mask;            /* Mask for ID string */
  57.   int action;            /* What to do with it */
  58.   char *command;        /* Command line, or for ACT_REJECT, */
  59.                 /* text of complaint message */
  60. };
  61.  
  62. /* Stuff to make stupid C compilers happy, and to fill in gaps */
  63.  
  64. #ifdef NOVOID
  65. #define void
  66. #endif
  67. #ifdef NOCONST
  68. #define const
  69. #endif
  70. #ifndef DEBUG
  71. #define DEBUG 0
  72. #endif
  73.  
  74. /* Function prototypes */
  75.  
  76. struct datatype *load_config(char *file, int *in_block_size);
  77. int getoffset(char *p, char **endpos);
  78. int getmagic(char *p, char **endpos, char *magic, char *mask);
  79. enum actions getaction(char *pos, char **cmd);
  80.  
  81. /* Global variables */
  82.  
  83. extern int debug_flag;
  84. extern char NO_WILD[];        /* Used as senitel value by getmagic() */
  85.